package enemies.factory.builders;

import java.net.URL;

import com.jme.math.Quaternion;
import com.jme.math.Vector3f;
import com.jme.scene.Node;
import com.model.md5.controller.MD5Controller;
import com.model.md5.importer.MD5Importer;
import com.model.md5.interfaces.IMD5Animation;
import com.model.md5.interfaces.IMD5Node;

import enemies.strategy.concretes.ConcreteStrategyInsane;

/** "ConcreteBuilder" */
public class SiruisEnemyBuilder extends EnemyBuilder {

	private MD5Controller bodyController;

	@Override
	public void asignarEstrategia() {
		getEnemy().setStrategy(new ConcreteStrategyInsane(mapControl, enemy, player));
	}

	@Override
	public void buildModel() {
		String dir = "data/model/Siruis/";
		URL md5mesh = getClass().getClassLoader().getResource(
				dir + "mesh.md5Mesh");
		URL animMarche = getClass().getClassLoader().getResource(
				dir + "caminar.md5Anim");
		
		
		MD5Importer importer = new MD5Importer();
		
		IMD5Node body = null;
		IMD5Animation marche = null;
		IMD5Animation victoire = null;
		try {

			importer.loadMesh(md5mesh, "ModelNode");
			body  = importer.getMD5Node();
			
			
			importer.loadAnim(animMarche, "Marche");
			marche = importer.getAnimation();
			
			victoire = importer.getAnimation();
			
			
			}
		catch (Exception e) {
			// TODO: handle exception
		}
		bodyController = new MD5Controller(body);
		bodyController.addAnimation(marche);
		bodyController.addAnimation(victoire);
		
		bodyController.setActive(true);
		bodyController.setRepeatType(1);
		//bodyController.setSpeed(3.5f);

		body.addController(bodyController);
		
		Node model = (Node) body;
		Quaternion rot;
		rot = model.getLocalRotation();
		rot.fromAngleAxis((float) +Math.toRadians(90), Vector3f.UNIT_Y);

		model.setLocalScale(.3f);
		
		getEnemy().getNode().attachChild(model);

	}

	@Override
	public void buildTexture() {
		// TODO Auto-generated method stub

	}



	@Override
	public void locate() {
			getEnemy().locate(mapControl.getWide()-2,mapControl.getHight()-2);
	}

	@Override
	public void setName() {
		getEnemy().setName("Siruis");
		
		
	}

}